
package ProOF.apl.problems.real.functions;

import ProOF.com.LinkerParameters;
import java.lang.Math;
/**
 *
 * @author Lucas
 */
public class RealFuncBR extends aRealFunction{
	
	private double a = 1;
	private double b;
	private double c;
	private double d = 6;
	private double g = 10;
	private double h;
	
	@Override
	public void parameters(LinkerParameters link) throws Exception {

	}
	
	@Override
	public int dimension() {
		return 2;
	}
	
	@Override
	public double min( int i ) {
		if (i == 0) {
			return -5;
		}
		return 0;
	}
	
	@Override
	public double max( int i ) {
		if (i == 0) {
			return 10;
		}
		return 15;
	}

	@Override
	public double f(double[] x) throws Exception {
		check(x);
		b = 5.1/(4*Math.PI*Math.PI);
		c = 5/Math.PI;
		h = 1/(8*Math.PI);

		return a*Math.pow(x[1] - b*x[0]*x[0] + c*x[0] - d, 2) + 
				g*(1 - h)*Math.cos(x[0]) + g;
	}

	@Override
	public String name() {
		return "BR";
	}

	@Override
	public String description() {
		return "Branin Problem";
	}	
}
